// 通用响应类型
export interface ApiResponse<T = unknown> {
  code: number
  data?: T
  msg: string
}

// 分页类型
export interface Pagination {
  page: number
  pageSize: number
  total: number
}

// 用户信息类型
export interface User {
  id: string
  username: string
  email?: string
  avatar?: string
}

// 学习进度类型
export interface SubjectProgress {
  [subject: string]: {
    completed: number
    total: number
    lastStudyTime: string
  }
}

// 用户设置类型
export interface UserSettings {
  theme: 'light' | 'dark'
  difficulty: 'easy' | 'medium' | 'hard'
  notifications: boolean
}

// 用户数据完整类型（对应后端数据结构）
export interface UserData {
  userId: string
  subjects: SubjectProgress
  practiceRecords: PracticeRecord[]
  settings: UserSettings
  createdAt: string
}

// 练习记录类型
export interface PracticeRecord {
  id: string
  subject: string
  score: number
  totalQuestions: number
  correctAnswers: number
  timeSpent: number
  completedAt: string
}

// 题目选项类型
export interface QuestionOption {
  value: string | number
  label: string
}

// 题目类型
export interface Question {
  id: string | number
  type: 'number-line' | 'fraction' | 'geometry' | 'function'
  question: string
  options?: QuestionOption[]
  correctAnswer: string | number
  explanation: string
}

// 计算请求参数类型
export interface CalculateParams {
  expression: string
  variables?: Record<string, number>
}

// 计算响应类型
export interface CalculateResponse {
  code: number
  data: { result: number }
  msg: string
}

// 生成题目请求参数类型
export interface GenerateQuestionsParams {
  subject: 'number-line' | 'fraction' | 'geometry' | 'function'
  difficulty: 'easy' | 'medium' | 'hard'
  count?: number
}

// 健康检查响应类型
export interface HealthResponse {
  code: number
  data: { message: string; timestamp: string }
  msg: string
}

// 题目类型信息
export interface QuestionType {
  type: string
  name: string
  description: string
  difficulties: string[]
}

// 题目类型列表响应
export interface QuestionTypesResponse {
  code: number
  data: QuestionType[]
  msg: string
}
